<include file="public/layout" />
<script type="text/javascript">
    /*
	 * 在线编辑器相 关配置 js 
	 *  参考 地址 http://fex.baidu.com/ueditor/
	 */
    window.UEDITOR_Admin_URL = "/public/plugins/Ueditor/";
    var URL_upload = "/index.php/admin/Ueditor/imageUp/savepath/goods.html";
    var URL_fileUp = "/index.php/admin/Ueditor/fileUp/savepath/article.html";
    var URL_scrawlUp = "/index.php/admin/Ueditor/scrawlUp/savepath/article.html";
    var URL_getRemoteImage = "/index.php/admin/Ueditor/getRemoteImage/savepath/article.html";
    var URL_imageManager = "/index.php/admin/Ueditor/imageManager/savepath/article.html";
    var URL_imageUp = "/index.php/admin/Ueditor/imageUp/savepath/article.html";
    var URL_getMovie = "/index.php/admin/Ueditor/getMovie/savepath/article.html";
    var URL_home = "";
</script>
<script type="text/javascript" charset="utf-8" src="/public/plugins/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/public/plugins/Ueditor/ueditor.all.min.js"> </script>
 <script type="text/javascript" charset="utf-8" src="/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">  
  
    var editor;
    $(function () {
        //具体参数配置在  editor_config.js  中
        var options = {
            zIndex: 999,
            initialFrameWidth: "95%", //初化宽度
            initialFrameHeight: 400, //初化高度
            focus: false, //初始化时，是否让编辑器获得焦点true或false
            maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign'
            , //允许的最大字符数 'fullscreen',
            pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
            autoHeightEnabled: true
         /*   autotypeset: {
                mergeEmptyline: true,        //合并空行
                removeClass: true,           //去掉冗余的class
                removeEmptyline: false,      //去掉空行
                textAlign: "left",           //段落的排版方式，可以是 left,right,center,justify 去掉这个属性表示不执行排版
                imageBlockLine: 'center',    //图片的浮动方式，独占一行剧中,左右浮动，默认: center,left,right,none 去掉这个属性表示不执行排版
                pasteFilter: false,          //根据规则过滤没事粘贴进来的内容
                clearFontSize: false,        //去掉所有的内嵌字号，使用编辑器默认的字号
                clearFontFamily: false,      //去掉所有的内嵌字体，使用编辑器默认的字体
                removeEmptyNode: false,      //去掉空节点
                                             //可以去掉的标签
                removeTagNames: {"font": 1},
                indent: false,               // 行首缩进
                indentValue: '0em'           //行首缩进的大小
            }*/,
        	toolbars: [
                   ['fullscreen', 'source', '|', 'undo', 'redo',
                       '|', 'bold', 'italic', 'underline', 'fontborder',
                       'strikethrough', 'superscript', 'subscript',
                       'removeformat', 'formatmatch', 'autotypeset',
                       'blockquote', 'pasteplain', '|', 'forecolor',
                       'backcolor', 'insertorderedlist',
                       'insertunorderedlist', 'selectall', 'cleardoc', '|',
                       'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                       'customstyle', 'paragraph', 'fontfamily', 'fontsize',
                       '|', 'directionalityltr', 'directionalityrtl',
                       'indent', '|', 'justifyleft', 'justifycenter',
                       'justifyright', 'justifyjustify', '|', 'touppercase',
                       'tolowercase', '|', 'link', 'unlink', 'anchor', '|',
                       'imagenone', 'imageleft', 'imageright', 'imagecenter',
                       '|', 'insertimage', 'emotion', 'insertvideo',
                       'attachment', 'map', 'gmap', 'insertframe',
                       'insertcode', 'webapp', 'pagebreak', 'template',
                       'background', '|', 'horizontal', 'date', 'time',
                       'spechars', 'wordimage', '|',
                       'inserttable', 'deletetable',
                       'insertparagraphbeforetable', 'insertrow', 'deleterow',
                       'insertcol', 'deletecol', 'mergecells', 'mergeright',
                       'mergedown', 'splittocells', 'splittorows',
                       'splittocols', '|', 'print', 'preview', 'searchreplace']
               ]
        };
        editor = new UE.ui.Editor(options);
        editor.render("content");  //  指定 textarea 的  id 为 goods_content

    }); 
</script>
<!--以上是在线编辑器 代码  end-->
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>讨论区 - 添加修改帖子</h3>
        <h5>添加或编辑论坛主题帖子</h5>
      </div>
    </div>
  </div>
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
      <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
      <span id="explanationZoom" title="收起提示"></span>
    </div>
    <ul>
      <li>请不要误删除帖子，不可恢复</li>
    </ul>
  </div>
  <form action="{:U('Discuss/addeditNote')}" method="post" class="form-horizontal" id="discuss_form">
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label for="t_mane"><em>*</em>标题</label>
        </dt>
        <dd class="opt">
          <input type="text" placeholder="名称" class="input-txt" name="title" value="{$discuss.title}">
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
            <label for="record_no">厂家</label>
        </dt>
        <dd class="opt">
              <select name="suppliers_id" id="suppliers_id" class="small form-control">
                <option value="0">请选择该帖所属厂家</option>                                      
                     <foreach name="suppliers" item="v" key="k" >                                                                                          
                       <option value="{$v['suppliers_id']}" <if  $v['suppliers_id'] eq $discuss['suppliers_id']>selected="selected"</if> >
                            {$v['suppliers_name']}
                       </option>
                     </foreach>
              </select>             
            <span class="err" id="err_suppliers_id" style="color:#F00; display:none;"></span>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
            <label for="record_no">帖子类型</label>
        </dt>
        <dd class="opt">
              <select name="type" id="type" class="small form-control">
                <option value="2">请选择该帖类型</option>     
                <foreach name="type" item="v" key="k" >                                                                                          
                    <option value="{$k}" <if  $k eq $discuss['type']>selected="selected"</if> >
                        {$v}
                    </option>
                </foreach>  
              </select>             
            <span class="err" id="err_type" style="color:#F00; display:none;"></span>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
            <label for="record_no">状态</label>
        </dt>
        <dd class="opt">
              <select name="status" id="type" class="small form-control">
                <option value="1">请选择该帖状态</option>     
                <foreach name="status" item="v" key="k" >                                                                                          
                    <option value="{$k}" <if  $k eq $discuss['status']>selected="selected"</if> >
                        {$v}
                    </option>
                </foreach>      
              </select>             
            <span class="err" id="err_type" style="color:#F00; display:none;"></span>
        </dd>
      </dl>
      <dl class="row"> 
	      	<dt class="tit">
	            <label for="record_no">帖子图片</label>
	        </dt>
            <dd class="opt">
                <table class="table table-bordered">
                    <tbody>
                    <tr>                                    
                        <td>                                    
                        <foreach name="discuss.img" item="vo" key="k" >
                            <div style="width:100px; text-align:center; margin: 5px; display:inline-block;" class="goods_xc">
                                <input type="hidden" value="{$vo}" name="img[]">
                                <a onClick="" href="{$vo}" target="_blank"><img width="100" height="100" src="{$vo}"></a>
                                <br>
                                <a href="javascript:void(0)" onClick="ClearPicArr2(this,'{$vo}')">删除</a>
                            </div>
                        </foreach>
                        
                        <div class="goods_xc" style="width:100px; text-align:center; margin: 5px; display:inline-block;">
                            <input type="hidden" name="img[]" value="" />
                            <a href="javascript:void(0);" onClick="GetUploadify(10,'','discuss','call_back2');"><img src="/public/images/add-button.jpg" width="100" height="100" /></a>
                            <br/>
                            <a href="javascript:void(0)">&nbsp;&nbsp;</a>
                        </div>                                        
                        </td>
                    </tr>                                              
                    </tbody>
                </table>
            </dd>            
      </dl>             
      <dl class="row">
	        <dt class="tit">
	            <label for="record_no">帖子内容</label>
	        </dt>
	        <dd class="opt">                    
	            <textarea class="span12 ckeditor" id="content" name="content" title="">{$discuss.content}</textarea>
	            <span class="err" id="err_goods_content" style="color:#F00; display:none;"></span>                    
	        </dd>
	    </dl> 
	    <if !empty($discuss)>
	    <input name="discuss_id" value="{$discuss.discuss_id}" type="hidden" />
	    </if>
      <div class="bot"><a id="submitBtn" class="ncap-btn-big ncap-btn-green" href="JavaScript:void(0);" onClick="ajax_submit_form('discuss_form','{:U('Discuss/addeditNote?is_ajax=1')}');">确认提交</a></div>
    </div>
  </form>
</div>
<script type="text/javascript">
    /*
     * 以下是图片上传方法
     */
    // 上传商品图片成功回调函数
    function call_back(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
    	$("#original_img2").attr('href', fileurl_tmp);
    }
 
    // 上传商品相册回调函数
    function call_back2(paths){
        
        var  last_div = $(".goods_xc:last").prop("outerHTML");	
        for (i=0;i<paths.length ;i++ )
        {                    
            $(".goods_xc:eq(0)").before(last_div);	// 插入一个 新图片
                $(".goods_xc:eq(0)").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
            $(".goods_xc:eq(0)").find('img').attr('src',paths[i]);// 修改他的图片路径
                $(".goods_xc:eq(0)").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('删除');
            $(".goods_xc:eq(0)").find('input').val(paths[i]); // 设置隐藏域 要提交的值
        } 			   
    }
    /*
     * 上传之后删除组图input     
     * @access   public
     * @val      string  删除的图片input
     */
    function ClearPicArr2(obj,path)
    {
    	$.ajax({
                    type:'GET',
                    url:"{:U('Admin/Uploadify/delupload')}",
                    data:{action:"del", filename:path},
                    success:function(){
                           $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片				 
                    }
		});
		// 删除数据库记录
    	$.ajax({
                    type:'GET',
                    url:"{:U('Admin/Goods/del_goods_images')}",
                    data:{filename:path},
                    success:function(){
                          //		 
                    }
		});		
    }
</script>    
</body>
</html>